<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div></div>

  <script>
    // 创建元素
    const p = document.createElement('p')

    p.innerHTML = 'Hello world!'

    const div = document.querySelector('div')
    div.appendChild(p)
  </script>
</body>

</html>